package br.com.primeira.entities;

import org.andengine.entity.Entity;

import br.com.primeira.util.Vector2;
import android.util.SparseArray;

public class Map extends Entity
{
	SparseArray<Tile> tiles;
	int mapWidth, mapHeight;
	
	public Map(SparseArray<Tile> tiles, int width, int height)
	{
		this.tiles = tiles;
		
		for(int i = 0; i < tiles.size(); i++)
			attachChild(tiles.valueAt(i));
		
		mapHeight = height;
		mapWidth = width;
	}
	
	public SparseArray<Tile> getTiles()
	{
		return tiles;
	}
	
	/*private Tile getTileAt(int x, int y)
	{
		return tiles.get((y * mapWidth) + x);
	}*/
	
	public Vector2 getCenter()
	{
		return new Vector2(mapWidth / 2, mapHeight / 2);
	}
	
	@Override
	public String toString()
	{
		String output = "";
		
		for (int i = 0; i < tiles.size(); i++)
			output += tiles.get(i) + "\n";
		
		return output;
	}
}
